from ..validator import validators
from .. import processor as proc
from .. import hal
from .base import BaseController

__all__ = [
    'UserController',
    'ClubController',
    'HonorController',
    'MemberController',
    'FollowerController',
    'LeagueController',
    'TeamController',
    'PlayerListController',
    'MatchController',
    'LineUpController',
    'EventController',
    'SpiritBoradController',
    'TableController',
    'SpiritController',
    'RankController',
    'DistrictController',
    'getfn',
]


def getfn(obj, attr):
    return getattr(obj, attr.lower())


class UserController(BaseController):
    """用户基本资料/users

    Auto Generated Code.
    """
    validator = validators.UserValidator
    processor = proc.UserProcessorObj
    document = hal.UserSchema
    collection = hal.UserCollection

    def c(self, collection):
        return {'users': collection}


class ClubController(BaseController):
    """俱乐部基本资料/clubs

    Auto Generated Code.
    """
    validator = validators.ClubValidator
    processor = proc.ClubProcessorObj
    document = hal.ClubSchema
    collection = hal.ClubCollection

    def c(self, collection):
        return {'clubs': collection}


class HonorController(BaseController):
    """俱乐部荣誉/honors

    Auto Generated Code.
    """
    validator = validators.HonorValidator
    processor = proc.HonorProcessorObj
    document = hal.HonorSchema
    collection = hal.HonorCollection

    def c(self, collection):
        return {'honors': collection}


class MemberController(BaseController):
    """俱乐部成员/members

    Auto Generated Code.
    """
    validator = validators.MemberValidator
    processor = proc.MemberProcessorObj
    document = hal.MemberSchema
    collection = hal.MemberCollection

    def c(self, collection):
        return {'members': collection}


class FollowerController(BaseController):
    """关注/followers

    Auto Generated Code.
    """
    validator = validators.FollowerValidator
    processor = proc.FollowerProcessorObj
    document = hal.FollowerSchema
    collection = hal.FollowerCollection

    def c(self, collection):
        return {'followers': collection}


class LeagueController(BaseController):
    """联赛基本数据/leagues

    Auto Generated Code.
    """
    validator = validators.LeagueValidator
    processor = proc.LeagueProcessorObj
    document = hal.LeagueSchema
    collection = hal.LeagueCollection

    def c(self, collection):
        return {'leagues': collection}


class TeamController(BaseController):
    """联赛球队/teams

    Auto Generated Code.
    """
    validator = validators.TeamValidator
    processor = proc.TeamProcessorObj
    document = hal.TeamSchema
    collection = hal.TeamCollection

    def c(self, collection):
        return {'teams': collection}


class PlayerListController(BaseController):
    """名单/playerlists

    Auto Generated Code.
    """
    validator = validators.PlayerListValidator
    processor = proc.PlayerListProcessorObj
    document = hal.PlayerListSchema
    collection = hal.PlayerListCollection

    def c(self, collection):
        return {'playerlists': collection}


class MatchController(BaseController):
    """球赛基本数据/matches

    Auto Generated Code.
    """
    validator = validators.MatchValidator
    processor = proc.MatchProcessorObj
    document = hal.MatchSchema
    collection = hal.MatchCollection

    def c(self, collection):
        return {'matches': collection}


class LineUpController(BaseController):
    """出场阵容/lineups

    Auto Generated Code.
    """
    validator = validators.LineUpValidator
    processor = proc.LineUpProcessorObj
    document = hal.LineUpSchema
    collection = hal.LineUpCollection

    def c(self, collection):
        return {'lineups': collection}


class EventController(BaseController):
    """球赛事件/events

    Auto Generated Code.
    """
    validator = validators.EventValidator
    processor = proc.EventProcessorObj
    document = hal.EventSchema
    collection = hal.EventCollection

    def c(self, collection):
        return {'events': collection}


class SpiritBoradController(BaseController):
    """球风记分牌/spiritborads

    Auto Generated Code.
    """
    validator = validators.SpiritBoradValidator
    processor = proc.SpiritBoradProcessorObj
    document = hal.SpiritBoradSchema
    collection = hal.SpiritBoradCollection

    def c(self, collection):
        return {'spiritborads': collection}


class TableController(BaseController):
    """积分榜/tables

    Auto Generated Code.
    """
    validator = validators.TableValidator
    processor = proc.TableProcessorObj
    document = hal.TableSchema
    collection = hal.TableCollection

    def c(self, collection):
        return {'tables': collection}


class SpiritController(BaseController):
    """球风榜/spirits

    Auto Generated Code.
    """
    validator = validators.SpiritValidator
    processor = proc.SpiritProcessorObj
    document = hal.SpiritSchema
    collection = hal.SpiritCollection

    def c(self, collection):
        return {'spirits': collection}


class RankController(BaseController):
    """排行榜/ranks

    Auto Generated Code.
    """
    validator = validators.RankValidator
    processor = proc.RankProcessorObj
    document = hal.RankSchema
    collection = hal.RankCollection

    def c(self, collection):
        return {'ranks': collection}


class DistrictController(BaseController):
    """行政区划/district

    Auto Generated Code.
    """
    validator = validators.DistrictValidator
    processor = proc.DistrictProcessorObj
    document = hal.DistrictSchema
    collection = hal.DistrictCollection

    def c(self, collection):
        return {'districts': collection}
